package com.atom.app.mvvm.net.interceptor

import okhttp3.Interceptor
import okhttp3.Response

class BaseInterceptor(private val headers: Map<String, String>) : Interceptor {

    override fun intercept(chain: Interceptor.Chain): Response {
        val builder = chain.request()
            .newBuilder()
        if (headers.isNotEmpty()) {
            headers.iterator().forEach { entry ->
                builder.addHeader(entry.key, entry.value).build()
            }
        }
        return chain.proceed(builder.build())
    }
}
